package com.example.commonlib.commonutil;

import android.support.annotation.StringRes;
import android.widget.Toast;

public class ToastUtil {
	private static Toast mToast;
	
    public static void toast(String text) {
		 if(mToast == null) {  
	            mToast = Toast.makeText(App.INSTANCE, text, Toast.LENGTH_SHORT);
	        } else {  
	            mToast.setText(text);    
	            mToast.setDuration(Toast.LENGTH_SHORT);
	        }  
	        mToast.show();
	}

	public static void toast(@StringRes int id){
    	toast(App.INSTANCE.getResources().getString(id));
	}
    
    public static void toastLong(String text) {
		 if(mToast == null) {  
	            mToast = Toast.makeText(App.INSTANCE, text, Toast.LENGTH_LONG);
	        } else {  
	            mToast.setText(text);
	        }
	        mToast.show();  
    }

    public static void toastLong(@StringRes int id){
    	toastLong(App.INSTANCE.getResources().getString(id));
	}
}
